package org.gwu.seuss.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ServiceFactory {

	private static ApplicationContext context;
	
	private static ApplicationContext getContext(){
		
		if(context == null){
			context = new ClassPathXmlApplicationContext("backend.xml");
		}
		return context;
	}
	
	public static UserService getUserService() {
		return (UserService)getContext().getBean("userServiceBean");
	}
	
	public static FileService getFileService() {
		return (FileService)getContext().getBean("fileServiceBean");
	}
	
	public static void initDataBaseService(){
		if(context == null){
			context = new ClassPathXmlApplicationContext("backend.xml");
		}
	}
	
}
